<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Performs an extended operation</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.ldap-exop-whoami.html">« ldap_exop_whoami</a></li>
      <li style="float: right;"><a href="function.ldap-explode-dn.html">ldap_explode_dn »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.ldap.html">LDAP 函数</a></li>
    <li>Performs an extended operation</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.ldap-exop" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ldap_exop</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.2.0, PHP 8)</p><p class="refpurpose"><span class="refname">ldap_exop</span> &mdash; <span class="dc-title">Performs an extended operation</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ldap-exop-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ldap_exop</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="class.ldap-connection.html" class="type LDAP\Connection">LDAP\Connection</a></span> <code class="parameter">$ldap</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$request_oid</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$request_data</code><span class="initializer"> = <strong><code>null</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">array</span> <code class="parameter">$controls</code><span class="initializer"> = <strong><code>null</code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$response_data</code><span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter reference">&$response_oid</code><span class="initializer"> = ?</span></span><br>): <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Performs an extended operation on the specified <code class="parameter">ldap</code> with
   <code class="parameter">request_oid</code> the OID of the operation and
   <code class="parameter">request_data</code> the data.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ldap-exop-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">ldap</code></dt>

    <dd>

     <p class="para">
      通过 <span class="function"><a href="function.ldap-connect.html" class="function">ldap_connect()</a></span> 返回的 <span class="classname"><a href="class.ldap-connection.html" class="classname">LDAP\Connection</a></span> 实例。
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">request_oid</code></dt>

    <dd>

     <p class="para">
       The extended operation request OID. You may use one of <strong><code>LDAP_EXOP_START_TLS</code></strong>, <strong><code>LDAP_EXOP_MODIFY_PASSWD</code></strong>, <strong><code>LDAP_EXOP_REFRESH</code></strong>, <strong><code>LDAP_EXOP_WHO_AM_I</code></strong>, <strong><code>LDAP_EXOP_TURN</code></strong>, or a string with the OID of the operation you want to send.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">request_data</code></dt>

    <dd>

     <p class="para">
       The extended operation request data. May be NULL for some operations like <strong><code>LDAP_EXOP_WHO_AM_I</code></strong>, may also need to be BER encoded.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">controls</code></dt>

    <dd>

     <p class="para">
      Array of <a href="ldap.controls.html" class="link">LDAP Controls</a> to send with the request.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">response_data</code></dt>

    <dd>

     <p class="para">
       Will be filled with the extended operation response data if provided.
       If not provided you may use ldap_parse_exop on the result object
       later to get this data.
     </p>
    </dd>

   
   
    <dt>
<code class="parameter">response_oid</code></dt>

    <dd>

     <p class="para">
       Will be filled with the response OID if provided, usually equal to the request OID.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ldap-exop-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   When used with <code class="parameter">response_data</code>, returns <strong><code>true</code></strong> on success or <strong><code>false</code></strong> on error.
   When used without <code class="parameter">response_data</code>, returns a result identifier or <strong><code>false</code></strong> on error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.ldap-exop-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">ldap</code> 参数接受 <span class="classname"><a href="class.ldap-connection.html" class="classname">LDAP\Connection</a></span>
  实例，之前接受 <a href="language.types.resource.html" class="link">资源(resource)</a>。
 </td>
</tr>

      <tr>
       <td>7.3.0</td>
       <td>
        Support for <code class="parameter">serverctrls</code> added
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ldap-exop-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4343">
    <p><strong>示例 #1 Whoami extended operation</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$ds&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">);&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;assuming&nbsp;the&nbsp;LDAP&nbsp;server&nbsp;is&nbsp;on&nbsp;this&nbsp;host<br /><br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;bind&nbsp;with&nbsp;appropriate&nbsp;dn&nbsp;to&nbsp;give&nbsp;update&nbsp;access<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$bind&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"cn=root,&nbsp;o=My&nbsp;Company,&nbsp;c=US"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"secret"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">$bind</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Unable&nbsp;to&nbsp;bind&nbsp;to&nbsp;LDAP&nbsp;server"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Call&nbsp;WHOAMI&nbsp;EXOP<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$r&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_exop</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">LDAP_EXOP_WHO_AM_I</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Parse&nbsp;the&nbsp;result&nbsp;object<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ldap_parse_exop</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$r</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$retdata</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Output:&nbsp;string(31)&nbsp;"dn:cn=root,&nbsp;o=My&nbsp;Company,&nbsp;c=US"<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$retdata</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Same&nbsp;thing&nbsp;using&nbsp;$response_data&nbsp;parameter<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$success&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_exop</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">LDAP_EXOP_WHO_AM_I</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NULL</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$retdata</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$retoid</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$success</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$retdata</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ldap_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">);<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Unable&nbsp;to&nbsp;connect&nbsp;to&nbsp;LDAP&nbsp;server"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ldap-exop-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ldap-parse-result.html" class="function" rel="rdfs-seeAlso">ldap_parse_result()</a> - Extract information from result</span></li>
    <li class="member"><span class="function"><a href="function.ldap-parse-exop.html" class="function" rel="rdfs-seeAlso">ldap_parse_exop()</a> - Parse result object from an LDAP extended operation</span></li>
    <li class="member"><span class="function"><a href="function.ldap-exop-whoami.html" class="function" rel="rdfs-seeAlso">ldap_exop_whoami()</a> - WHOAMI extended operation helper</span></li>
    <li class="member"><span class="function"><a href="function.ldap-exop-refresh.html" class="function" rel="rdfs-seeAlso">ldap_exop_refresh()</a> - Refresh extended operation helper</span></li>
    <li class="member"><span class="function"><a href="function.ldap-exop-passwd.html" class="function" rel="rdfs-seeAlso">ldap_exop_passwd()</a> - PASSWD extended operation helper</span></li>
   </ul>
  </p>
 </div>



</div></div></div></body></html>